 using UnityEngine;
using System.Collections;

public class CanTakeDamage : MonoBehaviour 
{
    
    public int Health = 100;
    protected int initalHealth;
	public int CurrHealth;
    public float gravataionalSpeed = .5f;


	protected virtual void Start()
	{
        
		FullHeal();
	}
	
	public void FullHeal()
	{
		CurrHealth = Health;
	}
	
	public virtual void TakeDamage(int dmg)
	{

        if((CurrHealth -= dmg) <= 0)
		{
			Die();
		}

	}

	
	public virtual void Die()
	{
			// needs more logic to determine it is enemy ...boss pieces
//        if ((gameObject.layer == LayerMask.NameToLayer("Enemy") && gameObject.tag  != "BossPiece1") || gameObject.tag == "Boss3")
//        {
//            Spawner.waveEnemies--;
//        }
		orbit orbits;
        if ((orbits = gameObject.GetComponent<orbit>()) != null)
		{
			Destroy(transform.parent.gameObject);
		}
		if(gameObject.tag == "Boss2")
		{
			GameObject city = GameObject.FindGameObjectWithTag("city").transform.GetChild(0).gameObject;
            if (PlayerPrefs.GetString("Diffculty") != "Boss")
            {
                city.SetActive(true);
            }
        }
            Destroy(gameObject);
	}
}
